package com.krtech.wecard.module.mayi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.krtech.wecard.module.mayi.entity.MayiDianzanCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MayiDianzanCountMapper extends BaseMapper<MayiDianzanCount> {
    @Update("update mayi_dianzan_count set count = (count + 1) where fk_pay_list_id = #{fk_pay_list_id}")
    int incre(Integer fkPayListId);

    @Select("select * from mayi_dianzan_count where id = #{id} for UPDATE")
    int lock(Integer id);

    /**
     * 修复点赞count数量问题
     */
    @Update("update mayi_dianzan_count set count = #{count} where fk_pay_list_id = #{fkPayListId}")
    public int fixCount(@Param("count") Integer count,@Param("fkPayListId") Integer fkPayListId);
}